package com.freestyle.sentinel.config;

import com.alibaba.cloud.sentinel.custom.SentinelAutoConfiguration;
import com.alibaba.csp.sentinel.annotation.aspectj.SentinelResourceAspect;
import com.freestyle.sentinel.GlobalHandlerImp;
import com.freestyle.sentinel.SentinelResourceAspectEx;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Created by rocklee on 2022/3/28 9:08
 */
@Configuration
@AutoConfigureBefore(SentinelAutoConfiguration.class)
public class SentinelConfig {
  @Bean
  @ConditionalOnMissingBean
  public SentinelResourceAspect sentinelResourceAspect() {
    return new SentinelResourceAspectEx(new GlobalHandlerImp());
  }
}
